<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Ativity extends CI_Controller {	
	/*构造函数,类初始化时，被调用*/
	function __construct()
	{
		parent::__construct();
		$this->load->database();
	}
	
	function loadrooms( $page = 0 ,$flag = '')
	{
		$model['name'] = 'gym';
		$condition = array(
			'level'=>'1',
		);
		$type = $this->_gamesid($_POST['seach']);
		
		$dbname = $this->db->dbprefix('u_c_') . $model['name'];
		
		//$this->db->cache_off();
		$number = $this->db->where($condition)->count_all_results($dbname);
		
		//$this->db->cache_on();
		 
		$this->db->from($dbname);
		$this->db->select('name, introduction , address , price nprice , type');
		$this->db->where($condition);
		$this->db->where("type like '%".$type."%'");
		$this->db->limit(6,($page-1)*6);

		$this->db->order_by('classid', 'DESC');
		
		$data['list'] = $this->db->get()->result_array();
		//var_dump($this->db);die();

		$config = array (
                   'flag' => $flag,
                   'list'  => $data['list']
                );
		$this->load->library('pre_li' ,$config );
		echo $this->pre_li->predata();
		
	}
	
	private function _gamesid($seach)
	{
		if( !$seach ) exit();
		$model['name'] = 'games';
		$dbname = $this->db->dbprefix('u_c_') . $model['name'];
		$condition = array(
			'name'=> $seach,
		);
		$number = $this->db->where($condition)->count_all_results($dbname);
		if($number < 1) exit();
		
		$this->db->from($dbname);
		$this->db->select('classid');
		$this->db->where($condition);
		
		$data = $this->db->get()->result_array();
		return $data[0]['classid'];
	}
	
	//调用不存在的方法
	/*function __call(){
        show_404();
    }*/
}
?>